package com.felight.ems.collections.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;

public class Employee {
	int id;
	String name;
	
	public Integer getId(){
		return id;
	}
	
	public String getName(){
		return name;
	}

	public Employee(int id, String name) {
		this.id = id;
		this.name = name;
	}

	public String toString() {
		return "ID:" + this.id + "Name:" + this.name;
	}

	public static void main(String[] args) {
		ArrayList<Employee> emp = new ArrayList<Employee>();
		emp.add(new Employee(1,"A"));
		emp.add(new Employee(2,"B"));
		emp.add(new Employee(3,"C"));
		System.out.println("Employee list size"+emp.size());
		Iterator<Employee> iterator = emp.iterator();
		Employee emp1;
		System.out.println("Employee list contains");
		for(Employee e : emp){
			emp1 = iterator.next();
			System.out.println("Employee id:"+emp1.getId());
			System.out.println("Employee name:"+emp1.getName());
		}
		
		Iterator<Employee> iterator1 = emp.iterator();
		while(iterator1.hasNext()){
			System.out.println(" "+(Employee)iterator1.next());
		}
		
		Iterator<Employee> iterator2 = emp.iterator();
		while(iterator2.hasNext()){
			System.out.println(" "+iterator2.next().getId());
		}
	}
}
